Đặt vé xe buýt trực tuyến bằng PHP / MySQLi

1 <?php
2     
//Start session
3     session_start();
4     
5     
//Connect to mysql server
6     require
"db.php";
7     
8     
//Function to sanitize values received from the form. Prevents SQL injection
9     function clean($str) {
10         $str = @trim($str);
11         
if(get_magic_quotes_gpc()) {
12             $str = stripslashes($str);
13         }
14         
return mysqli_real_escape_string($str);
15     }
16     
17     
//Sanitize the POST values
18     $login = ($_POST[
'username']);
19     $password = ($_POST[
'password']);
20     
21     
//Create query
22     $qry=
"SELECT * FROM admin WHERE username='$login' AND password='$password'";
23     $result=mysqli_query($conn,$qry);
24     
//while($row = mysqli_fetch_array($result))
25 // {
26 // $level=$row[
'position'];
27 // }

28     
//Check whether the query was successful or not
29     
if($result) {
30         
if(mysqli_num_rows($result) > 0) {
31             
//Login Successful
32             session_regenerate_id();
33             $member = mysqli_fetch_assoc($result);
34             $_SESSION[
'SESS_MEMBER_ID'] = $member['id'];
35             $_SESSION[
'SESS_FIRST_NAME'] = $member['username'];
36             session_write_close();
37             
//if ($level="admin"){
38             header(
"location: admin/dashboard.php");
39             exit();
40         }
else {
41             
//Login failed
42             header(
"location: index.php");
43             exit();
44         }
45     }
else {
46         die(
"Query failed");
47     }
48 ?>


Gõ tìm kiếm nhanh...